from sqlalchemy import create_engine
from sqlalchemy.orm import sessionmaker
from sqlalchemy import Column, Integer, String
from sqlalchemy.ext.declarative import declarative_base

engine = create_engine('sqlite:///treta.db')

Base = declarative_base()

class Aluno(Base):
    __tablename__ = 'alunos'
    id= Column(Integer, primary_key = True)
    nome = Column( String )
    numero = Column( Integer )
    curso = Column( String )

    def __init__(self, nome, numero, curso):
        self.nome = nome
        self.numero = numero
        self.curso = curso

Base.metadata.create_all(engine)

Session = sessionmaker(bind = engine)
session = Session()

aluno1 = Aluno('Tiago Bond', '007', 'Espeleologia')
aluno2 = Aluno('Barbara Bond', '008', 'Comunicacao')
aluno3 = Aluno('Manuel Bond', '009', 'Filosofia')

session.add(aluno1)
session.add(aluno2)
session.add(aluno3)

for obj in session.query(Aluno):
    print obj.nome

print

for obj in session.query(Aluno).filter(Aluno.nome=='Barbara Bond'):
    print obj.nome, obj.numero, obj.curso
